//    Copyright (C) Kherty.  All rights reserved.
using System.Diagnostics.Contracts;
using System.Reflection;
using OpenLS.Core.Notification;
using OpenLS.Core.Serialization;
using System.ComponentModel;
using OpenLS.Core;

namespace OpenLS.Chart
{
    public class NumericFormat : ViewModelBase, IOfficeXmlSerializable
    {
        private Format format;

        private bool sourceLinked;

        public Format Format
        {
            get { return format; }
            set { format = value;
                notifyPropertyChanged("Format"); }
        }


        public bool SourceLinked
        {
            get { return sourceLinked; }
            set { sourceLinked = value; notifyPropertyChanged("SourceLinked");}
        }

        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializable.ReadXml(ReadContext context)
        {
            using (var c = context.Read("numFmt"))
            {
                Format = Core.Format.Parse(c.GetString("formatCode"));
                SourceLinked = c.GetBoolean("sourceLinked");
                c.WarnIf("crtExt");
            }
        }

        void IOfficeXmlSerializable.WriteXml(WriteContext context)
        {
            using (WriteContext c = context.Write("numFmt"))
            {
                c.SetString("formatCode", Format.Code);
                c.SetBoolean("sourceLinked", SourceLinked);
                c.WarnIf("crtExt");
            }
        }

        #endregion

    
    }
}